package partition;

import java.util.List;

/**
 * create by yongli on 2021-09-13 08:50
 */

public class Lc82 {

    /**
     * 指针的个数，判断某个节点是否重复，i，j。 新数组k
     *
     * @param args
     */
    public static void main(String[] args) {
        // cur,front,end; 这个框架非常重要

        ListNode head = new ListNode();

        ListNode dummy = new ListNode();
        // dummy.next = cur;
        // vs cur = dummy.next;
        // 谁改变了？

        ListNode cur = dummy;

        ListNode front = head;
        ListNode end = head.next;

        while (end != null) {

            if(front.val == end.val){
                end = end.next;
            }else {
                if(front.next == end){
                    cur.next = front;
                    cur =  cur.next;
                }
                //
                front =front.next;
                end =end.next;
            }
        }
    }
}

class ListNode {
    int val;
    ListNode next;

    ListNode() {

    }

    ListNode(int val) {
        this.val = val;

    }

    ListNode(int val, ListNode next) {
        this.val = val;
        this.next = next;
    }
}